// 卡号和密码
let Idcard = "0101";
let Password = "123";

// 初始金额
let Money = 2000;

let readline = require("readline-sync");
let count = 3; //登录次数
while (count) {
    console.log("请输入卡号：");
    let userCard = readline.question("");
    console.log("请输入密码：");
    let userPassword = readline.question("");
    if (userCard === Idcard && userPassword === Password) {
        // 登录成功
        let flag = true; //循环开关
        while (flag) {
            console.log("请选择功能：1.查询  2.存钱  3.取钱  4.退出");
            let choice = readline.question("") * 1;
            switch (choice) {
                case 1:
                    console.log("当前余额为：", Money);
                    break;
                case 2:
                    console.log("存钱！");
                    console.log("请输入存入的金额：");
                    let addMoney=readline.question("")*1;
                    // 验证存入的金额是否符合条件
                    if(addMoney>0  && addMoney%100==0){
                        Money+=addMoney;
                        console.log("存入成功！");
                    }else{
                        console.log("存入金额有误！请重新输入！");
                    }
                    break;
                case 3:
                    console.log("取钱！");
                    console.log("请输入取出的金额：");
                    let decreaseMoney=readline.question("")*1;
                    // 验证取出的金额是否符合条件
                    if(decreaseMoney>0  && decreaseMoney%100==0 && decreaseMoney<=Money){
                        Money-=decreaseMoney;
                        console.log("取出成功！");
                    }else{
                        console.log("取出金额有误！请重新输入！");
                    }
                    break;
                case 4:
                    console.log("退出！");
                    flag=false;//关闭循环开关
                    count=0;//登录次数清零，结束最外层循环
                    break;
                default:
                    console.log("输入有误！请重新选择功能！");

            }
        }


    } else {
        console.log("卡号或密码输入有误！请重新输入！");
        count--;
    }
}